import java.util.Scanner;

public class HomeWork09_03{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        Human zhangSan = new Human("张三");
        Fruit fruit;
        
        System.out.println("有一个叫" + zhangSan.name + "的人");
        System.out.println("选择一个水果，送给" + zhangSan.name);
        System.out.println("请选择：\n"+
                           "1. 苹果\n"+
                           "2. 梨子\n"+
                           "3. 橘子\n");
                           
        int choose = scan.nextInt();
        switch(choose){
        case 1:
            fruit = new Apple();
            break;
        case 2:
            fruit = new Bear();
            break;
        case 3:
            fruit = new Orange();
            break;
        default:
            fruit = new Fruit();
            break;
        }
        
        zhangSan.smashedByFruit(fruit);
        zhangSan.eatFruit(fruit);
    }
}

class Fruit{
    String name = "水果";
    public void beEaten(){
        System.out.println(name + "被吃了.");    
    }
    public String getName(){
        return name;
    }
}

class Apple extends Fruit{
    String name = "苹果";
    public void beEaten(){
        System.out.println(name + "被吃了. " + name + "好红.");
    }
    public String getName(){
        return name;
    }
}

class Bear extends Fruit{
    String name = "梨子";
    public void beEaten(){
        System.out.println(name + "被吃了. " + name + "去火.");
    }
    public String getName(){
        return name;
    }
}

class Orange extends Fruit{
    String name = "橘子";
    public void beEaten(){
        System.out.println(name + "被吃了. " + name + "好酸."); 
    }
    public String getName(){
        return name;
    }
}

class Human{
    String name;
    public Human(String n){
        name = n;
    }
    public void smashedByFruit(Fruit fruit){
        System.out.println("好痛！，谁扔的" + fruit.getName() + "?!");
    }
    public void eatFruit(Fruit fruit){
        fruit.beEaten();
    }
}